package acme.ws;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import acme.entity.Order;

public class OrderServlet extends JSONServlet {
	
	private static final long serialVersionUID = 8875392317087332094L;
	
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		doPost(req, resp);
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		
		String shiptoAddress = req.getParameter("shiptoAddress");
		String orderItemId1 = req.getParameter("orderItemId1");
		String orderItemQty1 = req.getParameter("orderItemQty1");
		String orderItemId2 = req.getParameter("orderItemId2");
		String orderItemQty2 = req.getParameter("orderItemQty2");
		
		Order order = new Order(shiptoAddress, orderItemId1, orderItemQty1, orderItemId2, orderItemQty2);
		
		this.returnJSON(order, resp);
	}


	
}
